//
//  HZPeiziHeaderView.m
//  Stock_Stategy
//
//  Created by MayerF on 2017/12/12.
//  Copyright © 2017年 MayerF. All rights reserved.
//

#import "HZPeiziHeaderView.h"

@interface HZPeiziHeaderView()
@property (nonatomic, strong)UILabel *pOneLabel;
@property (nonatomic, strong)UILabel *pTwoLabel;
@property (nonatomic, strong)UILabel *pThreeLabel;
@property (nonatomic, strong)UILabel *pFourLabel;
@property (nonatomic, strong)UIView *pLine;
@end

@implementation HZPeiziHeaderView

#pragma mark -
#pragma mark 生命周期
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self initCommon];
        [self initConstraints];
    }
    return self;
}
- (void)initCommon {
    _pOneLabel = [UILabel new];
    _pTwoLabel = [UILabel new];
    _pThreeLabel = [UILabel new];
    _pFourLabel = [UILabel new];
    _pLine = [UIView new];
    
    _pOneLabel.textAlignment = _pTwoLabel.textAlignment =
    _pThreeLabel.textAlignment = _pFourLabel.textAlignment = NSTextAlignmentCenter;
    
    _pOneLabel.font = _pTwoLabel.font = _pThreeLabel.font = _pFourLabel.font = [UIFont systemFontOfSize:15];
    _pLine.backgroundColor = kMYHexToRGB(0xe4e3e6, 1);
//    _pOneLabel.textColor = _pTwoLabel.textColor =
//    _pThreeLabel.textColor = _pFourLabel.textColor = kGRAYColor;
}
- (void)initConstraints {
    [self addSubview:_pOneLabel];
    [self addSubview:_pTwoLabel];
    [self addSubview:_pThreeLabel];
    [self addSubview:_pFourLabel];
    [self addSubview:_pLine];
    
    [_pOneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(self);
        make.left.mas_equalTo(self);
        make.right.mas_equalTo(_pTwoLabel.mas_left);
    }];
    [_pTwoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(_pOneLabel);
        make.right.mas_equalTo(_pThreeLabel.mas_left);
    }];
    [_pThreeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(_pTwoLabel);
        make.right.mas_equalTo(_pFourLabel.mas_left);
    }];
    [_pFourLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(_pThreeLabel);
        make.right.mas_equalTo(self);
        make.width.mas_equalTo(@[_pOneLabel, _pTwoLabel, _pThreeLabel]);
    }];
    [_pLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.mas_equalTo(self);
        make.height.mas_equalTo(1);
    }];
}

- (void)setTexts:(NSArray *)texts
{
    if (texts.count == 4) {
        _pOneLabel.text = texts[0];
        _pTwoLabel.text = texts[1];
        _pThreeLabel.text = texts[2];
        _pFourLabel.text = texts[3];
    }
}

@end
